package com.kg.fiber.domain;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import com.ivan.toolkit.common.Configs;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
@NoArgsConstructor
public class AppConfig {
	
	public static Configs.Instance<AppConfig> instance = 
			new Configs.Instance<AppConfig>(AppConfig.class, true, true);
	
	/**
	 * 原始数据平铺时，每毫秒多少个点
	 */
	@XmlAttribute
	@Setter @Getter
	private int splitPerMillis = 2;
	
	/**
	 * 2的平方数，用于设置FFT的数量
	 */
	@XmlAttribute
	@Setter @Getter
	private int powerForFFTSize = 10;
	
	/**
	 * 用于积分数据的位置的表达式，
	 * <p>不同数据的位置采用‘,’号分隔，
	 * <p>连续数据可以用‘-’表示
	 * <p>如：‘0-4,6,8’
	 */
	@XmlAttribute
	@Setter @Getter
	private String integrateExpression = "1-10";
	
	
	/**
	 * 用于判断的数据数量
	 */
	@XmlAttribute
	@Setter @Getter
	private int judgeCount = 1000;
	
	/**
	 * 用于判断的阀值
	 */
	@XmlAttribute
	@Setter @Getter
	private double judgeThreshold = 0.0;
	
	/**
	 * 用于判断的限制数量
	 */
	@XmlAttribute
	@Setter @Getter
	private int judgeLimit = 600;
	
	/**
	 * 用于上报IP地址
	 */
	@XmlAttribute
	@Setter @Getter
	private String reportHost = "127.0.0.1";
	
	
	public int getFFTSize() {
		int power = this.powerForFFTSize;
		power = Math.max(power, 1);	
		power = Math.min(power, 20);
		return 0x01 << power;
	}

}
